package com.example.init;

import com.example.init.controller.HelloController;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class InitApplication {

    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(InitApplication.class, args);
//        HelloController controller = (HelloController) context.getBean("helloController");
//        HelloController controller1 = context.getBean(HelloController.class);
//        HelloController controller2 = context.getBean("helloController",HelloController.class);
//        System.out.println(controller);
//        System.out.println(controller1);
//        System.out.println(controller2);

        //Bean 演示
        // 名称获取bean
        Person person = (Person) context.getBean("person");
        System.out.println(person);
        // 类型获取bean(不保证唯一)
//        Person person1 = context.getBean(Person.class);
//        System.out.println(person1);
        // 名称+类型获取bean
        Person person2 = context.getBean("person", Person.class);
        System.out.println(person2);
    }

}
